package com.zlx.mall.basic.authentication.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.redisson.api.RObject;

import java.util.HashSet;
import java.util.Set;

/**
 * @author qingke
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class VerifyContext<T> extends ApplyContext {

    private T applyResult;
    private String value;

    private final Set<RObject> caches = new HashSet<>();

    public void addCache(RObject cache) {
        caches.add(cache);
    }

    public void clear() {
        if (!caches.isEmpty()) {
            caches.forEach(RObject::delete);
        }
    }

}
